#include "Comm.h"

void Comm::ServerRecvr(void* threadParams) {
	portIP* args = (portIP*)threadParams;
	char Buffer[10];
	cout << "Server Recvr Started on: " + args->ipAddress + "Port: " + itoa(args->port,Buffer, 10) << endl;
	try {
		SocketServer s = SocketServer(args->port, 10, BlockingSocket);
		string command = "";	
		Socket* client = s.Accept();
		cout << "Connection accepted!" << endl;
		while(true) {

			command = client->ReceiveLine();
			vector<string> splitInfo = vector<string>();
			Utils::SplitString(command, ",", splitInfo,false);
			switch(atoi(splitInfo[0].c_str()))
			{

			}
			if(command == "") {
				
			} else if(command =="END") {
				break;
			}
		}
		s.Close();
	}
	catch ( string str ) { cerr << str << endl; }
	catch ( ... ) { cerr << "unhandled exception\n"; }
}